package com.whuan.student.handler;

import com.whuan.student.VO.ResultVO;
import com.whuan.student.exceptions.StudentException;
import com.whuan.student.util.ResultVOUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
@Slf4j
public class StudentExceptionHandler {

    @ExceptionHandler(value = StudentException.class)
    @ResponseBody
    public ResultVO handler(StudentException e){
        log.info(".............................................");
        return ResultVOUtil.failed(e.getCode(),e.getMessage());
    }
}
